home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13294 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: solon.com!not-for-mail
  2. From: Michael Smith <msmith@mpx.com.au>
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 6 Apr 1996 08:51:39 -0600
  6. Organization: Emmenjay Consulting
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4k60dr$abu@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j06na$808@solutions.solon.com> <4jttan$3gf@solutions.solon.com> <4jv7n3$d8o@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Mailer: Mozilla 2.0 (Win16; I)
  13.  
  14. Kazimir Kylheku wrote:
  15. > Niall Smart <nsmart@indigo.ie> wrote:
  16. >  >
  17. >  >>: I recently wrote a loop that went like this:
  18. >  >
  19. >  >>: while (p < end_p)
  20. >  >>:    ++*p++;
  21. > I wouldn't hire a C maintainer who didn't know the basic 
  22. > precedence rules of the C language sufficiently well to 
  23. > know what ++*p++ does, 
  24.  
  25. Given an unlimited pool of applicants and an unlimited budget, 
  26. neither would I.
  27.  
  28. In the real world, people are not always hired for their impeccable 
  29. skills.  I don't have any say in who gets hired by my clients.  Often
  30. they are just out of Uni and expected to learn the finer points of 
  31. programming as they go.  I'm not saying that this is a good idea, simply 
  32. that it happens.
  33.  
  34. Considerations of programmer experience aside, an expression like:
  35.     while (p < end_p)
  36.         ++*p++;
  37. is fairly unusual these days.
  38.  
  39. If you learned programming in the bad old days when every byte was 
  40. critical and compiler optimization was ineffective, you saw lots of code 
  41. like that (and much worse).
  42.  
  43. If you learned programming in the last five years, you may have never 
  44. seen such a piece of code.  I agree that you should be able to figure it 
  45. out, but it adds complexity to the code and makes an error more likely.
  46.  
  47. If you can make your code as simple and self evident as possible, the 
  48. programmer can concentrate more effort on the algorithm, and that must 
  49. help.
  50.  
  51. I suggest that the code segment:
  52.     for ( ; p<end_p; p++)
  53.          ++(*p);
  54. is far easier to read.
  55.  
  56. Programmers make enough errors as it is.  Let's not make it any harder 
  57. than it needs to be.
  58.  
  59. -- 
  60. #####################################################################
  61. Michael Smith                                       msmith@mpx.com.au
  62. Emmenjay Consulting                 http://www.hutch.com.au/~emmenjay
  63. #####################################################################
  64.